package com.kl.model.pojo;

import com.kl.enums.Direct;
import com.kl.enums.State;
import com.kl.enums.TankType;
import com.kl.model.base.AbstractAttack;
import com.kl.model.base.AbstractTank;
import com.kl.model.base.DisposableBean;

import java.util.concurrent.CopyOnWriteArrayList;

/**
 * @author CC
 * time 2024-05-14
 * description
 *   坦克类
 *
 *
 *
 */
public class Tank extends AbstractTank implements Runnable, DisposableBean {

    public Tank(TankType tankType, int x, int y){
        super(tankType,x,y,1,
                1,1,
                Direct.UP, State.ALIVE,new CopyOnWriteArrayList<>());
    }

    @Override
    public void run() {

    }

    @Override
    public void destroy() {
        this.getAttacks().forEach(AbstractAttack::destroy);
        this.setStatus(null);
        this.getAttacks().clear();
        this.setAttacks(null);
        this.setOrigin(null);
        this.setDirect(null);
    }

    @Override
    public boolean isDestroyed() {
        return getStatus()==null || getStatus()==State.DEATH;
    }
}
